package com.uplift.mobile.realty.service.impl;

import com.uplift.common.base.ServiceReslut;
import com.uplift.mobile.realty.dao.RealtyRoomMapper;
import com.uplift.mobile.realty.model.RealtyRoomModel;
import com.uplift.mobile.realty.service.IRealtyRoomService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.UUID;

@Service
@Transactional
public class RealtyRoomServiceImpl implements IRealtyRoomService {

	@Autowired
	private RealtyRoomMapper realtyRoomMapper;

	@Override
	public List<Map<String, Object>> queryRealtyRoom(RealtyRoomModel realtyRoomModel) {
		return this.realtyRoomMapper.selectRealtyRoom(realtyRoomModel);
	}

	@Override
	public ServiceReslut addRealtyRoom(RealtyRoomModel realtyRoomModel) {
		realtyRoomModel.setId(UUID.randomUUID().toString().replaceAll("-", ""));
		realtyRoomModel.setState("1");
		realtyRoomModel.setCreateTime(new Date());
		return ServiceReslut.newServiceReslut(realtyRoomMapper.insertRealtyRoom(realtyRoomModel), "");
	}

	@Override
	public ServiceReslut updateRealtyRoom(RealtyRoomModel realtyRoomModel) {
		realtyRoomModel.setUpdateTime(new Date());
		return ServiceReslut.newServiceReslut(realtyRoomMapper.updateRealtyRoom(realtyRoomModel), "");
	}

	@Override
	public ServiceReslut deleteRealtyRoom(RealtyRoomModel realtyRoomModel) {
		realtyRoomModel.setState("0");		//删除状态
		realtyRoomModel.setUpdateTime(new Date());
		return ServiceReslut.newServiceReslut(realtyRoomMapper.updateRealtyRoom(realtyRoomModel), "");
	}

}
